import Vuex from 'vuex'
import Vue from 'vue'
Vue.use(Vuex)

import child2 from './modules/child2'
import child3 from './modules/child3'

export default new Vuex.Store({
    state: {
        msg: '我爱你'
    },
    mutations: {
        SET_MSG(state, text) {
            state.msg = text
        }
    },
    actions: {
        changeMessage({ commit }, text) {
            commit('SET_MSG', text)
        }
    },
    getters: {
        allMsg(state) {
            return '老张' + state.msg
        }
    },
    modules: {
        child2,
        child3
    }
})